﻿namespace Sidvall.FileSystemManager
{
    public partial class SystemContext
    {
        #region Public Members

        public const string SystemName = "ModelContainer";
        public global::Sidvall.FileSystemManager.Net.Services.V1.Model.EntityCache EntityCache { get; set; }
        public global::Sidvall.FileSystemManager.Net.Services.V1.Model.EntityFacade EntityFacade { get; set; }
        
        #endregion
        #region Factory Members

        static partial void OnCreateSystemContext(SystemContext item);
        private static readonly object _Mutex = new object();
        private static volatile SystemContext _Current;
        public static SystemContext Current
        {
            get
            {
                if (_Current == null)
                {
                    lock (_Mutex)
                    {
                        if (_Current == null)
                        {
                            var item = new SystemContext()
                            {
                                EntityCache = new global::Sidvall.FileSystemManager.Net.Services.V1.Model.EntityCache(),
                                EntityFacade = new global::Sidvall.FileSystemManager.Net.Services.V1.Model.EntityFacade(),
                            };
                            OnCreateSystemContext(item);
                            _Current = item;
                        }
                    }
                }
                return _Current;
            }
            set
            {
                lock (_Mutex)
                {
                    _Current = value;
                }
            }
        }

        #endregion
        #region Constructors

        public SystemContext()
        {
        }

        #endregion
    }
}